package com.acme.bankapp.domain.bank;

import com.acme.bankapp.domain.bank.exceptions.NotEnoughFundsException;

/**
 * Created by anton on 8/18/14.
 */
public class SavingsAccount extends AbstractAccount {
    public SavingsAccount(double balance) {
        super(balance);
    }


    @Override
    public void withdraw(double x) throws NotEnoughFundsException {
        if (x > this.maximumAmountToWithdraw()) {
            throw new NotEnoughFundsException(this.maximumAmountToWithdraw());
        }
        this.balance -= x;
    }

    @Override
    public double maximumAmountToWithdraw() {
        return this.balance;
    }

    @Override
    public String toString() {
        return "\tSaving account with balance: " + this.getBalance() + "\n";
    }
}
